<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class VirusBossRepository {

    /*
     * 设置新boss
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function setBoss($param) {
        $boss =app('model_virus_boss')->orderBy('id','desc')->first();
        if ($boss){
          $set= app('model_virus_boss')->where('id',$boss->id)->update($param);
        }else{
          $set= app('model_virus_boss')->create($param);
        }
        if ($set) return $set;
        throw new BasicException(93087);
    }

     /*
     * 获取boss详情
     * @return bool
     * @throws BasicException
     * */
     public function  getBossDetail(){
         $getBossDetail =app('model_virus_boss')->select('start_time','end_time','start_time_slot','end_time_slot','refresh_seconds','attack_price','lowest_blood','highest_blood')->orderBy('id','desc')->first();
         if ($getBossDetail){
             $getBossDetail=$getBossDetail->toArray();
         }
         return $getBossDetail;
     }

}


?>